{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" action="save" id="data-form">
                        {if condition="$data['id']!=''"}<input type="hidden" value="{$data['id']}" name="id">{/if}
                        {if condition="$pid!=''"}<input type="hidden" value="{$pid}" name="pid">{/if}
                        <!--表单项-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>菜单名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="name" value="{$data['name']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>菜单编码</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="code" value="{$data['code']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图标</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="icon"  value="{$data['icon']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="about"  value="{$data['about']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>排序</label>
                            <div class="col-sm-10">
                                <input type="number"  class="form-control" name="sort" value="{$data['sort']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否按钮</label>
                            <input type="hidden" value="{$data['type']}" id="type-value">
                            <div class="col-sm-10">
                                <div class="radio-inline i-checks">
                                    <label>
                                        <input type="radio"   value="0" name="type" id="type-0"> <i></i> 否</label>
                                </div>
                                <div class="radio-inline i-checks">
                                    <label>
                                        <input type="radio" value="1" name="type" id="type-1"> <i></i>是</label>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <!--/表单项-->
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="saveData();">保存</button>
                                <button class="btn btn-white" type="button" onclick="layer_close()">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{include file="public/footer" /}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(function () {
        //初始化复选框
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });

        //是否按钮赋值
        var type=$("#type-value").val();
        if(type==0){
            $("#type-0").iCheck('check');
        }else {
            $("#type-1").iCheck('check');
        }
    });

    /**
     * 表单提交
     */
    function saveData() {
        $.ajax({
            url: "save",
            type: 'POST',
            dataType: 'json',
            data: $("#data-form").serializeJSON(),
            success: function (res) {
                if (res.rc == 0) {
                    parent.toastr.success("操作成功！");
                    //关闭弹窗
                    layer_close();
                    //刷新菜单
                    parent.getMenus();
                } else {
                    layer.msg(res.msg,{icon: 2});
                }
            }
        });
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
